# -*- coding: utf-8 -*-
from match import Extractor
import regex as re
import os


class BeiHaiRenLiangJieExtractor(Extractor):

    @staticmethod
    def is_my_job(file_path):
        return True

    @staticmethod
    def extract(text):
        result = {}
        have_hui_zui = re.search(r"(刑事和解)", text) is not None
        result["刑事和解"] = int(have_hui_zui)
        if result["刑事和解"] == 0:
            result["刑事和解"] += 2
        have_hui_zui = re.search(r"(被害人自愿和解)", text) is not None
        result["被害人自愿和解"] = int(have_hui_zui)
        if result["被害人自愿和解"] == 0:
            result["被害人自愿和解"] += 2
        have_hui_zui = re.search(r"(达成了和解)", text) is not None
        result["双方当事人和解"] = int(have_hui_zui)
        if result["双方当事人和解"] == 0:
            result["双方当事人和解"] += 2
        have_hui_zui = re.search(r"(被害人谅解)", text) is not None
        result["被害人谅解"] = int(have_hui_zui)
        if result["被害人谅解"] == 0:
            result["被害人谅解"] += 2
        return result


if __name__ == '__main__':
    print(BeiHaiRenLiangJieExtractor.extract("与被害人在警方的主持下达成了和解协议"))
